<?php
class Ajax extends CF_Controller
{

	function __construct()
	{
		parent::__construct();
	}

	public function qr_code($qr_type = 'caipu', $id = NULL)
	{
		$this->load->library('qr_code');
		switch ($qr_type)
		{
			case 'caipu':
				if (empty($id) || !is_numeric($id)) redirect(site_url());
				$this->qr_code->jpg(site_url('ajax/go_caipu_url/?id='.$id));
			break;
			case 'article':
				if (empty($id) || !is_numeric($id)) redirect(site_url());
				$this->qr_code->jpg(site_url('ajax/go_article_url/?id='.$id));
			break;
			default:
				exit($id);
		}
		
	}

	public function go_caipu_url()
	{
		$cpid = $this->input->get('id');
		header('HTTP/1.1 301 Moved Permanently');
		header('Location:http://m.ichufang.cn/recipe/'.$cpid);
	}

	public function go_article_url()
	{
		$wzid = $this->input->get('id');
		header('HTTP/1.1 301 Moved Permanently');
		header('Location:http://m.ichufang.cn/article/views/'.$wzid);
	}

	public function captcha_image()
	{
        if ($this->config->item('captcha_registration'))
		{
			$this->load->helper('captcha');

			$vals = array(
				'font_path'	 	=> './data/captcha/1.ttf',
				'font_size'  	=> '',
				'img_width'	 	=> 100,
				'img_height' 	=> 30
			);
			// 验证码方法session已存
			return create_captcha($vals);									
		}
	}

}

/* End of file ajax.php */
/* Location: ./application/controllers/ajax.php */